package net.notdot.aeauth;

import java.util.ArrayList;

import android.os.Parcel;
import android.os.Parcelable;

@SuppressWarnings("serial")
public class ListaAvisos extends ArrayList<Aviso> implements Parcelable {
	public ListaAvisos(){
		
	}
	public ListaAvisos(Parcel in){
		readFromParcel(in);
	}
	
	@SuppressWarnings("rawtypes")
	public static final Parcelable.Creator CREATOR =
    	new Parcelable.Creator() {
	    public ListaAvisos createFromParcel(Parcel source) {
	          return new ListaAvisos(source);
	    }
	    public ListaAvisos[] newArray(int size) {
	          return new ListaAvisos[size];
	    }
	};
	
	private void readFromParcel(Parcel in) {
		// TODO Auto-generated method stub
		this.clear();
		int size = in.readInt();
		for(int i=0;i<size;i++){
			Aviso a = new Aviso();
			a.setId(in.readString());
			a.setActividad(in.readString());
			a.setCuanto(in.readString());
			in.readList(a.getCuando(),String.class.getClassLoader());
			a.setAutor(in.readString());
			a.setFecha(in.readString());
			a.setRepeticion(in.readString());
			this.add(a);
		}
		
	}
	@Override
	public int describeContents() {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public void writeToParcel(Parcel dest, int flags) {
		// TODO Auto-generated method stub
		int size = this.size();
		dest.writeInt(size);
		for (int i = 0; i < size; i++) {
			Aviso a = this.get(i);
			dest.writeString(a.getId());
			dest.writeString(a.getActividad());
			dest.writeString(a.getCuanto());
			dest.writeList(a.getCuando());
			dest.writeString(a.getAutor());
			dest.writeString(a.getFecha());
			dest.writeString(a.getRepeticion());
		}
	}

}
